<?php include("menucontenttop.php");?>
<table border="0" cellpadding="5" cellspacing="0" width="100%">
	<tr>
	<?php
		$id = $_GET['id'];
		$querycat = "select * from categories where id=$id";
		$resultcat = mysql_query($querycat);
		 while($rowcat = mysql_fetch_array($resultcat)){?>
			<td class="sp_home_title" width="100%">
				<?php echo $rowcat['cateName'];?> 
			</td>
			<?php
			}
			?>
		</td>
	</tr>
</table>

<table cellspacing="2" cellpadding="0"  class="sp_home" align="left" width="100%">
	<tr>
		<?php
		$id=$_GET['id'];
		//TrungDQ- Get productID from categories_products table
		$query_cate_pro="select * from categories_products where categoryId=$id ORDER BY id DESC ";
		$cate_pro_result = mysql_query($query_cate_pro);
		while($the_cate_pro_result = mysql_fetch_array($cate_pro_result))
		{		
			$productID =  $the_cate_pro_result['productId'];			
		//TrungDQ-End
			$querypro="select * from productdetails where id = $productID AND state='on' ORDER BY id DESC LIMIT 0,16 ";
			$resultpro=mysql_query($querypro);
			$a=1;
			while($rowpro = mysql_fetch_array($resultpro)){?>
			<td height="100%" align="center" valign="top">
				<div class="sp_moi_content">
				
				<div class="khung_sp_tc_main">
					<table border="0" cellspacing="0" cellpadding="0" width="100%">
						<tr>
							<td class="content-box" width="100%">
								<div align="left" ><a href="index.php?page=listviewproductDetail&id=<?php echo $rowpro['id'];?>" ><?php echo $rowpro['productname'];?></a></div>
							</td>
						</tr>
						<tr>
							<td class="content-second" width="100%"><?php echo $rowpro['productDetail'];?></td>
						</tr>
						<tr>
							<td class="date_created">Ngày tạo : <?php $ngay = date('d/m/Y', $row['dateCreated']); echo $ngay;?>  -  <span class="view-detail-download"><a href="index.php?page=listviewproductDetail&id=<?php echo $rowpro['id'];?>" >Xem chi tiết tải về</a></span> - Lượt tải về : <?php echo $rowpro['download'];?>  - Lượt xem : <?php echo $rowpro['productView'];?></td>
						</tr>
						<tr>
							<td align="center" valign="bottom" width="100%">
							
							<!--<div class="luotxem">Lượt xem : <?php echo $row['productView'];?></div>-->
							</td>
						</tr>
						<tr>
							<td align="center" valign="bottom" width="100%" height="10%">
								 <!--<input type="button" value="Mua hàng" onclick="addtocart(<?=$row['id']?>)" />-->
							</td>
						</tr>
					</table>
				</div>
				</div>
			</td>
			<div style="display:none;" id="<?php echo $row['id'];?>"><?php echo $row['productDetail'];?></div>
			 <?php
			if($a%1==0){
				echo "<tr></tr>";	
			}
			$a=$a+1;
		   }
		}
		?>
	</tr>
</table>